﻿//创建时间: 2011-1-24
//创建作者: 李 城
//功能说明: 用户操作 映射
//最后修改: 2011-1-24
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Reflection;
using TRPOP.Common;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.Plugin
{
    /// <summary>
    /// 日志操作接口
    /// </summary>
    public class ILogAccess
    {
        const string mstrNamespace = "TRPOP.CMS.Log";
        const string mstrLogClassName = "TRPOP.CMS.Log.LogManage";
        public static ILog GetInstance()
        {
            /*
             * 
             * 之前的实现方式 lcheng
             * 2011.07.07
            ICache oICache = ICacheAccess.GetInstance();
            if (oICache.IsExist(CacheKeys.Sys_ILogAccess) == false)
            {
                ILog oILog = (ILog)Assembly.Load(mstrNamespace).CreateInstance(mstrLogClassName);
                oICache.Save(CacheKeys.Sys_ILogAccess,
                               oILog,
                               SYSConfig.CahceSeconds);
                return oILog;
            }
            return (ILog)oICache.Read(CacheKeys.Sys_ILogAccess);
             */
            return CacheHelper.GetByICache<ILog>(
                    CacheKeys.Sys_ILogAccess,
                    SYSConfig.SystemVar_CahceSeconds,
                    ICacheAccess.GetInstance(),
                    () =>
                    {
                        return (ILog)Assembly.Load(mstrNamespace).CreateInstance(mstrLogClassName);
                    }
            );
        }
        //信息点击映射的处理方法
        const string mstrContentCilckLogClassName = "TRPOP.CMS.Log.ContentClickLogManage";
        public static IContentClickLog GetContentClickInstance()
        {
            /*
             *
             * 2011.07.07 lcheng    原来的代码
             * 
             * 
            ICache oICache = ICacheAccess.GetInstance();
            if (oICache.IsExist(CacheKeys.Sys_IContentClickAccess) == false)
            {
                IContentClickLog oIContentClickLog = (IContentClickLog)Assembly.Load(mstrNamespace).CreateInstance(mstrContentCilckLogClassName);
                oICache.Save(CacheKeys.Sys_IContentClickAccess,
                               oIContentClickLog,
                               SYSConfig.CahceSeconds);
                return oIContentClickLog;
            }
            return (IContentClickLog)oICache.Read(CacheKeys.Sys_IContentClickAccess);
             */ 
            return CacheHelper.GetByICache<IContentClickLog>(
                    CacheKeys.Sys_IContentClickAccess,
                    SYSConfig.SystemVar_CahceSeconds,
                    ICacheAccess.GetInstance(),
                    () =>
                    {
                        return (IContentClickLog)Assembly.Load(mstrNamespace).CreateInstance(mstrContentCilckLogClassName);
                    }
            );
        }

    }
}
